package com.example.nio;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class RedisClient2 {
    public static void main(String[] args) throws IOException {
        System.out.println("RedisClient2 启动");
        Socket socket = new Socket("localhost", 6379);
        OutputStream outputStream = socket.getOutputStream();
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String next = scanner.next();
            if (next.equalsIgnoreCase("quit")) {
                break;
            }

            socket.getOutputStream().write(next.getBytes());
            System.out.println("发送:" + next);
        }

        outputStream.close();
        socket.close();
    }
}
